// pages/loadingPage/loadingPage.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    animations: []
  },

  create() {
    let animations = []
    const that = this
    for (let i = 0; i < 10; i++) {
      let animation = wx.createAnimation({
        delay: 0,
        duration: 150+ 50 * i,
        timingFunction: 'ease',
      })
      animation.opacity(0).step()
      // animation.opacity(1).step({duration:400})
      animations.push(animation.export())
      this.setData({ animations: animations })

    }
    animations = []
    setTimeout(() => {
      for (let i = 0; i < 10; i++) {
        let animation = wx.createAnimation({
          delay: 0,
          duration:350 * i,
          timingFunction: 'ease',
        })
        animation.opacity(1).step()
        animations.push(animation.export())
        that.setData({
          animations: animations
        })
      }

    }, 500)


  },

  goHome(){
    let animations = []
    const that = this
    
    setTimeout(() => {
      for (let i = 0; i < 10; i++) {
        let animation = wx.createAnimation({
          delay: 0,
          duration:350 * i,
          timingFunction: 'ease',
        })
        animation.opacity(0).step()
        animations.push(animation.export())
        that.setData({
          animations: animations
        })
      }
      setTimeout(()=>{
        wx.redirectTo({
          url: '/pages/index/index',
        })
      },1000)

    }, 2000)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      animations:[]
    })
    this.create()

    this.goHome()

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})